<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */

$this->title = Yii::t('app', '编辑分类');
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', '分类'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-index">
    <section class="panel panel-default">
        <header class="panel-heading font-bold">分类信息</header>
        <div class="panel-body">
            <form class="form-horizontal ajax-submit" method="post">
                <div class="form-group">
                    <label class="col-sm-2 control-label">分类名称</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="Category[name]" value="<?= \yii\helpers\ArrayHelper::getValue($info, 'name')?>">
                        <span class="help-block m-b-none"></span><!--注释表单-->
                    </div>
                </div>
                <div class="line line-dashed line-lg pull-in"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">排序</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="Category[sort]" value="<?= \yii\helpers\ArrayHelper::getValue($info, 'sort')?>">
                        <span class="help-block m-b-none"></span><!--注释表单-->
                    </div>
                </div>
                <div class="line line-dashed line-lg pull-in"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">父级分类</label>
                    <div class="col-sm-10">
                        <select name="Category[parent_id]" class="form-control m-b">
                            <option value="0">顶级分类</option>
                            <?php foreach($category as $item):?>
                                <option
                                        value="<?= \yii\helpers\ArrayHelper::getValue($item, 'cat_id')?>"
                                    <?= isset($info['parent_id']) && $info['parent_id'] == $item['cat_id'] ? 'selected': '';?>
                                >
                                    <?= \yii\helpers\ArrayHelper::getValue($item, 'html')?>
                                </option>
                            <?php endforeach;?>
                        </select>
                    </div>
                </div>
                <div class="line line-dashed line-lg pull-in"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">备注</label>
                    <div class="col-sm-10">
                        <textarea class="form-control parsley-validated" rows="6" name="Category[extra]"></textarea>
                    </div>
                </div>
                <div class="line line-dashed line-lg pull-in"></div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-2">
                        <button type="button" class="btn btn-default">取消</button>
                        <button type="submit" class="btn btn-primary">保存</button>
                    </div>
                </div>
                <input type="hidden" name="Category[cat_id]" value="<?= \yii\helpers\ArrayHelper::getValue($info, 'cat_id')?>">
                <input type="hidden" value="<?php echo Yii::$app->request->csrfToken; ?>" name="<?= Yii::$app->request->csrfParam?>" >
            </form>
        </div>
    </section>


</div>
